package com.CloudDream.Command.Player;

import com.CloudDream.Gui.gui.RecipeGui;
import com.CloudDream.MoonCake;
import com.handy.lib.command.IHandyCommandEvent;
import com.handy.lib.util.BaseUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

public class RecipeCommand implements IHandyCommandEvent {

    private MoonCake instance = MoonCake.getInstance();

    @Override
    public String command() {
        return "recipe";
    }

    @Override
    public String permission() {
        return "mooncake.default";
    }

    public void onCommand(final CommandSender commandSender, Command command, String s, String[] args) {
        if(BaseUtil.isNotPlayer(commandSender).booleanValue()){
            commandSender.sendMessage(MoonCake.prefix + "§7该命令只能由玩家执行");
            return;
        }
        Player p = (Player) commandSender;
        (new BukkitRunnable(){
            @Override
            public void run() {
                switch (args[1]) {
                    default:
                        p.sendMessage(MoonCake.prefix + "§c输入月饼名字后才能查看配方");
                        break;
                    case "莲蓉":
                        p.openInventory(RecipeGui.open(p.getPlayer(), "lr"));
                        break;
                    case "五仁":
                        p.openInventory(RecipeGui.open(p.getPlayer(), "wuren"));
                        break;
                    case "果味":
                        p.openInventory(RecipeGui.open(p.getPlayer(), "gw"));
                        break;
                    case "蛋黄":
                        p.openInventory(RecipeGui.open(p.getPlayer(), "dh"));
                        break;
                    case "肉松":
                        p.openInventory(RecipeGui.open(p.getPlayer(), "rs"));
                        break;
                    case "玫瑰":
                        p.openInventory(RecipeGui.open(p.getPlayer(), "mg"));
                        break;
                    case "冰糖":
                        p.openInventory(RecipeGui.open(p.getPlayer(), "bt"));
                        break;
                }
            }
        }).runTaskAsynchronously(MoonCake.getInstance());
    }
}